<?php
/**
 * Created by PhpStorm.
 * User: WX-D
 * Date: 2018/4/20
 * Time: 14:20
 */
namespace app\common\model;
use think\Db;
use think\Model;

class User extends Model{
    protected function setPasswordAttr($value){
        return md5($value);
    }
    public function index ($name){
        return $this->where(['name'=>$name])->find();
    }
    public function add($data){
        return $this->allowField(true)
            ->validate('user.add')
            ->save($data);
    }
    public function remove($id){
        return $this->where(['id'=>$id])
            ->delete();
    }
}